<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yuxin.common.util.*" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.google.gson.Gson" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	String dataId = request.getParameter("id");
	String status = request.getParameter("status");
    Connection conn = DBUtil.getConnection();
	Map user = ((Map)session.getAttribute("user"));
    try{
    	if(StringUtils.hasText(dataId)){
	    	Map dataMap = DBUtil.queryUniqueResult(conn,"SELECT * FROM P_ORDERS WHERE ID = ? ",dataId);
	    	List prodList = DBUtil.queryList(conn,"SELECT * FROM P_ORDER_GOODS WHERE ORDER_ID = ? ORDER BY CREATE_TIME DESC ",dataId);
	        request.setAttribute("prodList",prodList);
	        request.setAttribute("dataMap",dataMap);
    	}
    }catch (Exception e){
        e.printStackTrace();
    }finally {
        DBUtil.close(conn);
    }
%>
<!DOCTYPE html>
<html>
<head>
    <%@ include file="/meta.jsp" %>
    <title>${site_title}</title>
</head>
<body>
<div class="zx-container" >
	<%@ include file="/trader/menu.jsp" %>
	<div class="span9 offset3">
		<%@ include file="/header_bg.jsp" %>
        <div class="row-fluid zx-bg-cont">
        	<div class="span12 subpage-title">
	            <div class="left"><h4 class="title">订单详情</h4></div>
	            <div class="right" style="float:none;right: 10px;">
	               <button class="btn" onclick="history.back()"><i class="icon icon-share-alt"></i> 返回</button>
	            </div>
	        </div>
	        <div class="row-fluid">
	            <div class="span6">
	                <label class="control-label" style="width:90px;display:inline-block;">订单号</label>
	                <div class="controls" style="display:inline-block;color: #888888;">${dataMap.CODE}</div>
	            </div>
	            <div class="span6 control-group">
	                <label class="control-label"  style="width:90px;display:inline-block;">交易号</label>
	                <div class="controls" style="display:inline-block;color: #888888;">${dataMap.ID}</div>
	            </div>
        	</div>
	        <div class="row-fluid">
	            <div class="span6">
	                <label class="control-label" style="width:90px;display:inline-block;">下单时间</label>
	                <div class="controls" style="display:inline-block;color: #888888;"><fmt:formatDate value="${dataMap.CREATE_TIME}" pattern="yyyy-MM-dd"/></div>
	            </div>
	            <div class="span6 control-group">
	                <label class="control-label"  style="width:90px;display:inline-block;">成交时间</label>
	                <div class="controls" style="display:inline-block;color: #888888;"><fmt:formatDate value="${dataMap.UPDATE_TIME}" pattern="yyyy-MM-dd"/></div>
	            </div>
	        </div>
	        
            <table class="table table-bordered" style="border: 1px solid #CCC;">
                <thead>
                    <tr>
                        <th>商品</th>
                        <th>状态</th>
                        <th>价格</th>
                        <th>数量</th>
                        <th>总价</th>
                    </tr>
                </thead>
            	<c:forEach items="${dataList}" var="data" varStatus="status">
            		<tr>
            			<td>
            				<img src="${ctx}/${data.TITLE_IMG}" />
            				<span>${data.TITLE}</span>
            			</td>
            			<td>已确认收货</td>
            			<td>￥${data.PRICE}</td>
            			<td>${data.AMOUNT}</td>
            			<td>￥(${data.PRICE}*${data.AMOUNT})</td>
            		</tr>
            	</c:forEach>
            </table>
        </div>
		<%@ include file="/footer_bg.jsp" %>
	</div>
</div>
<script>
$(document).ready(function(){
	var status = "${param.status}" ||"1";
	$("#menu_order_"+status).addClass("active");
});
</script>
</body>
</html>